package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {

    /**
     * 根据id查询，是微信登陆用方法
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid};")
    User getByOpenId(String openid);

    /**
     * 根据id查询，是支付方法
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id};")
    User getById(Long id);

    /**
     * 插入数据
     * @param user
     */
    void insert(User user);

    /**
     * 根据openid查询
     * @param currentId
     * @return
     */
    @Select("select name from user where openid = #{currentId} ;")
    String getName(Long currentId);

    /**
     * 查询新建与历史用户
     * @param begin
     * @param end
     * @return
     */
    Long getCountUser(LocalDateTime begin, LocalDateTime end);
}
